Data Cleaning

Checking if, in the above data all the dates between Feb 25, 2022 and Dec 12, 2011 are present or not.

As clearly seen, our data has all the dates between the above mentioned range.

Removing 'K' and '.' from the Volume column

Analysis and Pre-processing

LSTM Modelling

Considering the whole dataframe for training and forecasting

Statistical Analysis

Along the black line, we have found the rolling mean of 150 days, so as to generalise the trend of oil prices.

Expanding upon the data and finding average trends of continuous 150 days.

ETS Decompoition

We apply an additive model when it seems that the trend is more linear and the seasonality and trend components seem to be constant over time. A multiplicative model is more appropriate when we are increasing (or decreasing) at a non-linear rate.

We can see a strong seasonal component

Simple Moving Average (SMA)

We just showed how to calculate the SMA based on some window. However, basic SMA has some weaknesses:

Smaller windows will lead to more noise, rather than signal It will always lag by the size of the window It will never reach to full peak or valley of the data due to the averaging. Does not really inform you about possible future behavior, all it really does is describe trends in your data. Extreme historical values can skew your SMA significantly

EWMA will allow us to reduce the lag effect from SMA and it will put more weight on values that occured more recently (by applying more weight to the more recent values, thus the name). The amount of weight applied to the most recent values will depend on the actual parameters used in the EWMA and the number of periods given a window size.

FORECASTING

Forecasting with the Holt-Winters Method

Stationarity or Not

This plot indicates non-stationary data, as there are a large number of lags before ACF values drop off.

AR(p) AutoRegressive Model

Fitting AR(1) Model

Fit an AR(p) model where statsmodels chooses p

Augmented Dickey-Fuller Test

ARIMA

This confirms that we reached stationarity after the first difference.